﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AiXiu.Common;
using AiXiu.Model;
using AiXiu.BLL;
using AiXiu.IBLL;
using Newtonsoft.Json;

namespace AiXiu.WebSite.Handler
{
    /// <summary>
    /// ajax实现登录
    /// </summary>
    public class Login : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            ILoginAndRegisterBLL login = new LoginAndRegisterBLL();
            string userNameOrMobile = context.Request["zh"];
            string pwd = context.Request["pwd"];
            OperResult<TBUsers> res = Convert.ToBoolean(context.Request["is_username"]) ? login.loginByUserName(userNameOrMobile, pwd) : login.loginByMobileNumber(userNameOrMobile, pwd);

            context.Response.Write(JsonConvert.SerializeObject(res));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}